<% include_stylesheet 'admin/extensions/assets/assets' %>

<% form_for record, :url => url, :html => {:multipart => true, :id => 'asset_upload', 'data-onsubmit_status'=>'Uploading Asset&#8230;'} do |f| %>
  <p>Click or drag files here to upload</p>
  <%= f.file_field :uploads, :multiple => true %>
  
  <p class="buttons">
    <%= f.submit 'Upload Asset', :class=>'button' %>
    or <%= link_to 'Cancel', admin_assets_path %>
  </p>
<% end %>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js"></script>
<% include_stylesheet 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/base/jquery-ui.css' %>
<script type="text/javascript">jQuery.noConflict();</script>
<script src="/jquery.fileupload/jquery.fileupload.js" type="text/javascript"></script>
<script src="/jquery.fileupload/jquery.fileupload-ui.js" type="text/javascript"></script>
<% include_stylesheet '/jquery.fileupload/jquery.fileupload-ui.css' %>
<script type="text/javascript">
  (function($) {
    $(function () {
      $('form#asset_upload').fileUploadUI({
        uploadTable: $('#assets'),
        downloadTable: $('#assets'),
        buildUploadRow: function (files, index) {
          return $('<li>' + files[index].name +
                   '<span class="file_upload_progress"><div><\/div><\/span>' +
                   '<span class="file_upload_cancel">' +
                   '<button class="ui-state-default ui-corner-all" title="Cancel">' +
                   '<span class="ui-icon ui-icon-cancel">Cancel<\/span>' +
                   '<\/button><\/span><\/li>');
        },
        buildDownloadRow: function (file) {
          return $(file.markup);
        }
      });
    });
  }(jQuery));
</script>
